package com.yjt.fresh.activity;

import android.view.View;
import android.webkit.WebView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.HttpManager;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.listener.HttpOnNextListener;
import com.yjt.fresh.R;
import com.yjt.fresh.api.ApiGetShopAgreement;
import com.yjt.fresh.api.ApiGetUserAgreement;
import com.yjt.fresh.base.BaseSimpleActivity;
import com.yjt.fresh.bean.BeanAgreement;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 开店协议
 * Created by mcc on 2018/7/21.
 */

public class AtyShopArgument extends BaseSimpleActivity {
    @BindView(R.id.back)
    RelativeLayout mBack;
    @BindView(R.id.tvAppAtyTitleAndContentTitle)
    TextView mTvTitle;
    @BindView(R.id.wbAppAtyTitleAndContent)
    WebView mWb;

    @Override
    protected int getContentView() {
        return R.layout.app_aty_title_content;
    }

    @Override
    protected void initViews() {
        ButterKnife.bind(this);
        mTvTitle.setText("开店协议");
        mWb.getSettings().setUseWideViewPort(true);
        mWb.getSettings().setDisplayZoomControls(false); //隐藏原生的缩放控件
    }

    @Override
    protected void initEvent() {

        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        getData();
    }

    HttpOnNextListener<BeanAgreement> mArgumentListener = new HttpOnNextListener<BeanAgreement>() {
        @Override
        public void onNext(BeanAgreement beanAgreement) {
            mWb.loadDataWithBaseURL(null, beanAgreement.getCONTENT(), "text/html", "utf-8", null);
        }

        @Override
        public void onReLogin() {
            toLogin();
        }
    };
    private void getData() {
        ApiGetShopAgreement apiGetUserAgreement = new ApiGetShopAgreement(mArgumentListener,mContext,true,false,true);
        HttpManager.getInstance().doHttpDeal(apiGetUserAgreement);
    }

}
